package com.wty.gw.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wty.gw.util.PageParamReq;
import com.wty.gw.dao.NewsMapper;
import com.wty.gw.model.Do.NewsDO;
import com.wty.gw.model.query.NewsQuery;
import com.wty.gw.service.NewsService;
import com.wty.gw.model.vo.NewsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class NewsServiceImpl implements NewsService{

	@Autowired
    private NewsMapper newsMapper;

    @Override
    public void add(NewsDO newsDo) {
        newsMapper.insert(newsDo);
    }

    @Override
    public void delete(Long id) {
        newsMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void update(NewsDO newsDo) {
        newsMapper.updateByPrimaryKeySelective(newsDo);
    }

    @Override
    public PageInfo<NewsVo> listByPage(NewsQuery newsQuery) {
        PageHelper.startPage(newsQuery.getPageNo(), newsQuery.getPageSize());

        return new PageInfo(newsMapper.listBycompanyId(newsQuery));
    }

    @Override
    public NewsDO get(Long id) {
        return newsMapper.selectByPrimaryKey(id);
    }
	
	
	
	
	
	
}